package cn.interestingshop.servlet.client;

import cn.interestingshop.entity.Classify;
import cn.interestingshop.entity.Goods;
import cn.interestingshop.service.ClassifyService;
import cn.interestingshop.service.GoodsService;
import cn.interestingshop.service.impl.ClassifyServiceImpl;
import cn.interestingshop.service.impl.GoodsServiceImpl;
import cn.interestingshop.vo.ClassifyVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/GoodsDetailServlet")
public class GoodsDetailServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.设置编码
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        //2.获取请求参数
        String id = request.getParameter("id");
        //3.调用service进行业务处理
        GoodsService service=new GoodsServiceImpl();
        Goods goods = service.selectOne(Integer.parseInt(id));

        //4.分析返回结果
        request.setAttribute("goods",goods);
        request.getRequestDispatcher("Product.jsp")
                .forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
